﻿@using JewererBasic
@using JewererBasic.Models
@model IEnumerable<BAG>

<h2>Order Detail: @ViewBag.OrderId</h2>

@using (Html.BeginForm("OrderDetail", "Order"))
{
    <fieldset>
        <div>
            <a href="/Order/Details/@ViewBag.OrderId">
                <input type="button" value="BACK" />
            </a>
            <a href="@Url.Action("ExportReportBagsByOrderId", "Report", new { orderId = @ViewBag.OrderId })">
                <input type="button" value="PRINT BAGs" />
            </a>
        </div>

        <table>
            <tr>
                <td>
                    <fieldset>
            <legend>BAGs LIST</legend>

            <table>
                <tr>
                    <td>
                        <fieldset>
                            <legend>SEARCH</legend>
                            <table>
                                <tr>
                                    <td style="text-align:center;"><b>Bag Id</b></td>
                                    <td style="text-align:center;"><b>Product</b></td>
                                </tr>
                                <tr>
                                    <td>@Html.TextBox("tbSearch", "", new { @title = "Input bag id to search.", placeholder = "Bag Id..." })</td>
                                    <td>@Html.DropDownList("ddlProductInOrder", new SelectList(ViewBag.OrderProducts), "All", new { style = "width: 150px", title = "Select product to filter." })</td>
                                    <td><input type="submit" value="SEARCH" name="submit" title="Search Bag" /></td>
                                </tr>
                            </table>
                        </fieldset>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div>
                @if (Model != null && Model.Count() > 0)
                {
                    var gd = new WebGrid(
                        Model,
                        canPage: true,
                        rowsPerPage: 10,
                        selectionFieldName: "selectedRow",
                        ajaxUpdateContainerId: "gridContent"
                    );
                    gd.Pager(WebGridPagerModes.NextPrevious);

                    <div>
                        @gd.GetHtml(
                                    tableStyle: "table",
                                    headerStyle: "head",
                                    rowStyle: "row",
                                    alternatingRowStyle: "altRow",
                                    selectedRowStyle: "selectRow",
                                    columns: gd.Columns(
        //gd.Column(header: "Bag", format: @<div>@Html.Partial("_PartialBagProcessDetail", new ItemBag { Bag = item.Bag, Processes = item.Processes })</div>),
                                    gd.Column(header: "Bag No", format: @<div style="width: 100px; text-align: center;"><a href="@Url.Action("BagProcessDetail", new { id = item.Id })">@item.Id</a></div>),
                                    gd.Column(header: "Product", format: @<div style="width: 200px; text-align: center;"><a href="@Url.Action("ExportReportProduct", "Report", new { productId = @item.ORDER_PRODUCT.IdProduct })">@item.ORDER_PRODUCT.IdProduct</a></div>),
                                    gd.Column(header: "Quantity", format: @<div style="width: 100px; text-align: center;">@item.Number</div>),
                                    gd.Column(header: "Finish (Y/N)", format: @<div style="width: 100px; text-align: center;">@(item.Finish == 1 ? "Y" : "N")</div>),
                                    gd.Column(header: "Action", format: @<div style="width: 100px; text-align: center;"><span>@Html.ActionLink("Details", "BagProcessDetail", new { id = item.Id }, new { @style = "max-width: 100px" })</span></div>)
                                ))
                    </div>
                }
            </div>
                    </td>
                </tr>
            </table>
        </fieldset>
                </td>
            </tr>
        </table>
        
    </fieldset>
}